package com.nlp.algorithm.hanoi;

/**
 * https://www.cnblogs.com/xsyfl/p/6926269.html 常用算法
 * https://blog.csdn.net/tyhj_sf/article/details/53447731  模拟退火算法
 * https://github.com/haifengl/smile
 * 汉若塔问题
 * @author ygsong.abcft
 *
 */
public class Hanoi {
	
	private static int count = 1;
	
	public static void main(String[] args) {
		moved(4, "第一根柱子", "第二根柱子", "第三根柱子");
	}

	private static void moved(int i, String a, String b, String c) {
		if (i == 1) {
			disPaly(1, a,b);
		}else {
			moved(i-1, a, c, b);
			
			disPaly(i, a, b);
			
			moved(i - 1, c, b, a);
		}
	}

	private static void disPaly(int i, String a, String b) {
		System.out.println("第"+count+"步：移动第"+i+"个塔从"+a+"到"+b);
		count++;
	}

}
